<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="UTF-8">
<!-- modify by zhangwei -->
<!-- 百度站长 -->
<meta name="baidu-site-verification" content="MdPKZBgY0U">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">



  <meta name="google-site-verification" content="8DKRuNxJDPU2k6cNyVhLe_eSqGk-R8oiYk8iKMg5gwI">














  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/uploads/favicon.ico?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/uploads/favicon.ico?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/uploads/favicon.ico?v=5.1.4">


  <link rel="mask-icon" href="/uploads/favicon.ico?v=5.1.4" color="#222">





  <meta name="keywords" content="Java,编译注解,">





  <link rel="alternate" href="/atom.xml" title="班德尔城" type="application/atom+xml">






<meta name="description" content="Annotation注解在Android的开发中的使用越来越普遍，例如EventBus、ButterKnife、Dagger2等，记一次使用插件annotationProcessor实现下载监听注解框架，为什么不用android-apt呢，我不会告诉你android-apt不再维护了。">
<meta name="keywords" content="Java,编译注解">
<meta property="og:type" content="article">
<meta property="og:title" content="Java编译注解-自动生成代码">
<meta property="og:url" content="https://tiimor.cn/Java编译注解-自动生成代码/index.html">
<meta property="og:site_name" content="班德尔城">
<meta property="og:description" content="Annotation注解在Android的开发中的使用越来越普遍，例如EventBus、ButterKnife、Dagger2等，记一次使用插件annotationProcessor实现下载监听注解框架，为什么不用android-apt呢，我不会告诉你android-apt不再维护了。">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="http://cdn.tiimor.cn/images/%E5%94%AF%E7%BE%8E%E7%AF%87%EF%BC%8D%E4%B8%96%E7%95%8C%E8%BF%99%E4%B9%88%E5%A4%A7%EF%BC%8C%E5%8F%88%E6%9C%89%E8%B0%81%E8%83%BD%E4%BA%86%E8%A7%A3%E6%88%91%E5%91%A2.jpg">
<meta property="og:image" content="http://cdn.tiimor.cn/images/Annotation%E9%A1%B9%E7%9B%AE%E7%BB%93%E6%9E%84.png">
<meta property="og:image" content="http://cdn.tiimor.cn/images/ProxyClassCounter.png">
<meta property="og:image" content="http://cdn.tiimor.cn/images/SingleThreadActivity$$DownloadListenerProxy.png">
<meta property="og:updated_time" content="2019-03-17T06:47:42.378Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Java编译注解-自动生成代码">
<meta name="twitter:description" content="Annotation注解在Android的开发中的使用越来越普遍，例如EventBus、ButterKnife、Dagger2等，记一次使用插件annotationProcessor实现下载监听注解框架，为什么不用android-apt呢，我不会告诉你android-apt不再维护了。">
<meta name="twitter:image" content="http://cdn.tiimor.cn/images/%E5%94%AF%E7%BE%8E%E7%AF%87%EF%BC%8D%E4%B8%96%E7%95%8C%E8%BF%99%E4%B9%88%E5%A4%A7%EF%BC%8C%E5%8F%88%E6%9C%89%E8%B0%81%E8%83%BD%E4%BA%86%E8%A7%A3%E6%88%91%E5%91%A2.jpg">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":true,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '3AUIZWGETM',
      apiKey: '5fcd6d51d892fffe3480c5b37f5fd4fa',
      indexName: 'Tiimor',
      hits: {"per_page":8},
      labels: {"input_placeholder":"搜索","hits_empty":"未发现与「${query}」相关的内容","hits_stats":"${hits} 条相关条目，使用了 ${time} 毫秒"}
    }
  };
</script>



  <link rel="canonical" href="https://tiimor.cn/Java编译注解-自动生成代码/">





  <title>Java编译注解-自动生成代码 | 班德尔城</title>
  




<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  ga('create', 'UA-96457043-1', 'auto');
  ga('send', 'pageview');
</script>


  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?abb97f8f68c9e5eb2217d3111c64e696";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

  <!-- modify by zhangwei -->
  <!-- 下雪的动画 -->
  <div class="canvas-snow">
    <canvas id="canvas" style="margin: 0;  padding: 0;top:0; left: 0; right: 0; background: transparent; position: absolute;" width="1366" height="105"></canvas>
      <script>

      var canvasBgImg = {
        start: function () {
          this.canvas = document.getElementById('canvas')
          this.ctx = this.canvas.getContext("2d")
          this.canvas.width = window.innerWidth
          this.canvas.height = 105
          this.starList = []
        },
        drawLine: function (ctx, x1, y1, x2, y2) {
          ctx.beginPath()
          ctx.strokeStyle = '#ffffff'
          ctx.lineTo(x1, y1)
          ctx.lineTo(x2, y2)
          ctx.stroke()
        },
        canvasSingleSnow: function (snowSize) {
          var singleSnow = document.createElement('canvas'),
            ctxSingle = singleSnow.getContext('2d')
          singleSnow.setAttribute('width', snowSize * 2)
          singleSnow.setAttribute('height', snowSize * 2)
          for (var i = 0; i < 6; i++) {
            ctxSingle.save()
            ctxSingle.translate(snowSize, snowSize)
            ctxSingle.rotate(Math.PI * 2 * i / 6)
            this.drawLine(ctxSingle, 0, 0, snowSize, 0)
            ctxSingle.restore()
          }
          return singleSnow
        },
        canvasAllSnow: function (centerSnow) {
          var canvasSnow = document.createElement('canvas'),
            ctxSnow = canvasSnow.getContext('2d'),
            bigSnow = this.canvasSingleSnow(centerSnow),
            smallSnow = this.canvasSingleSnow(centerSnow / 3),
            sizeSnow = centerSnow * 3 / 5,
            rSnow = centerSnow - sizeSnow / 2
          canvasSnow.setAttribute('width', centerSnow * 2)
          canvasSnow.setAttribute('height', centerSnow * 2)
          ctxSnow.drawImage(bigSnow, 0, 0, bigSnow.width, bigSnow.height, 0, 0, centerSnow * 2, centerSnow * 2)
          for (var i = 0; i < 6; i++) {
            ctxSnow.save()
            ctxSnow.translate(centerSnow, centerSnow)
            ctxSnow.rotate(Math.PI * 2 * i / 6)
            ctxSnow.drawImage(smallSnow, 0, 0, smallSnow.width, smallSnow.height, rSnow - sizeSnow / 2,
              -sizeSnow / 2, sizeSnow, sizeSnow)
            ctxSnow.restore()
          }
          return canvasSnow
        },
        init: function () {
          this.start()
          for (var i = 0; i < 75; i++) {
            this.starList.push({
              drawFunc: this.canvasAllSnow(15),
              width: Math.random() * this.canvas.width,
              height: Math.random() * this.canvas.height,
              speed: Math.random() * 1.5 + .5,
              scale: Math.random() * 12 + 5,
              angel: 0
            })
          }
          var self = this,
            loop = function () {
              self.ctx.clearRect(0, 0, self.canvas.width, self.canvas.width)
              for (var i = 0; i < 75; i++) {
                self.ctx.save()
                self.starList[i].height = self.starList[i].height + self.starList[i].speed
                self.starList[i].angel += 2
                self.ctx.translate(self.starList[i].width, self.starList[i].height)
                self.ctx.rotate(self.starList[i].angel * Math.PI / 360)
                self.ctx.translate(-self.starList[i].width, -self.starList[i].height)
                self.ctx.drawImage(self.starList[i].drawFunc, 0, 0,
                  self.starList[i].drawFunc.width, self.starList[i].drawFunc.height,
                  self.starList[i].width - self.starList[i].scale / 2,
                  self.starList[i].height - self.starList[i].scale / 2,
                  self.starList[i].scale, self.starList[i].scale)
                if (self.starList[i].height > self.canvas.height) {
                  self.starList[i] = Object.assign(self.starList[i], {
                    height: -self.starList[i].scale,
                    width: Math.random() * this.canvas.width
                  })
                }
                self.ctx.restore()
              }
              requestAnimationFrame(loop)
            }
          requestAnimationFrame(loop)
        }
      }
      canvasBgImg.init()
      </script>

    </div>


    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <!-- modify by zhangwei -->
        <!-- 圣诞帽 -->
        <img src="/uploads/santa-hat.png" id="santa" style="height: 41px; position: absolute; left: -40px; top: -20px; transform: rotate(-45deg); z-index: 9000;">

        <span class="logo-line-before"><i></i></span>
        <span class="site-title">班德尔城</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">微笑，简单，奋发</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br>
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-guestbook">
          <a href="/guestbook" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-send"></i> <br>
            
            留言
          </a>
        </li>
      
        
        <li class="menu-item menu-item-favourite">
          <a href="/favourite" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-bookmark"></i> <br>
            
            收藏
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br>
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  
  <div class="algolia-popup popup search-popup">
    <div class="algolia-search">
      <div class="algolia-search-input-icon">
        <i class="fa fa-search"></i>
      </div>
      <div class="algolia-search-input" id="algolia-search-input"></div>
    </div>

    <div class="algolia-results">
      <div id="algolia-stats"></div>
      <div id="algolia-hits"></div>
      <div id="algolia-pagination" class="algolia-pagination"></div>
    </div>

    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
  </div>




    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://tiimor.cn/Java编译注解-自动生成代码/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Tiimor">
      <meta itemprop="description" content>
      <meta itemprop="image" content="/uploads/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="班德尔城">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Java编译注解-自动生成代码</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-09-10T13:58:52+08:00">
                2017-09-10
              </time>
            

            

            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/好好学习/" itemprop="url" rel="index">
                    <span itemprop="name">好好学习</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/Java编译注解-自动生成代码/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count gitment-comments-count" data-xid="/Java编译注解-自动生成代码/" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          
          
             <span id="/Java编译注解-自动生成代码/" class="leancloud_visitors" data-flag-title="Java编译注解-自动生成代码">
               <span class="post-meta-divider">|</span>
               <!-- modify by zhangwei -->
               <!-- 去掉阅读的眼睛图标，阅读次数改为℃ -->
			   
                 <span class="post-meta-item-text">热度 </span>
               
                 <span class="leancloud-visitors-count"></span>
				 <span>℃</span>
             </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p><img src="http://cdn.tiimor.cn/images/%E5%94%AF%E7%BE%8E%E7%AF%87%EF%BC%8D%E4%B8%96%E7%95%8C%E8%BF%99%E4%B9%88%E5%A4%A7%EF%BC%8C%E5%8F%88%E6%9C%89%E8%B0%81%E8%83%BD%E4%BA%86%E8%A7%A3%E6%88%91%E5%91%A2.jpg" alt="Android" title="&#x4E16;&#x754C;&#x8FD9;&#x4E48;&#x5927;&#xFF0C;&#x53C8;&#x6709;&#x8C01;&#x80FD;&#x4E86;&#x89E3;&#x6211;&#x5462;"></p>
<p><strong>Annotation&#x6CE8;&#x89E3;</strong>&#x5728;Android&#x7684;&#x5F00;&#x53D1;&#x4E2D;&#x7684;&#x4F7F;&#x7528;&#x8D8A;&#x6765;&#x8D8A;&#x666E;&#x904D;&#xFF0C;&#x4F8B;&#x5982;EventBus&#x3001;ButterKnife&#x3001;Dagger2&#x7B49;&#xFF0C;<strong>&#x8BB0;&#x4E00;&#x6B21;&#x4F7F;&#x7528;&#x63D2;&#x4EF6;annotationProcessor&#x5B9E;&#x73B0;&#x4E0B;&#x8F7D;&#x76D1;&#x542C;&#x6CE8;&#x89E3;&#x6846;&#x67B6;</strong>&#xFF0C;&#x4E3A;&#x4EC0;&#x4E48;&#x4E0D;&#x7528;android-apt&#x5462;&#xFF0C;&#x6211;&#x4E0D;&#x4F1A;&#x544A;&#x8BC9;&#x4F60;android-apt&#x4E0D;&#x518D;&#x7EF4;&#x62A4;&#x4E86;&#x3002;</p>
<a id="more"></a>
<hr>
<p>Javadoc&#x4EE3;&#x7801;&#x6CE8;&#x89E3;-&#x4EE3;&#x7801;&#x6587;&#x6863;&#xFF1A;<a href="http://tiimor.cn/Javadoc-%E4%BB%A3%E7%A0%81%E6%96%87%E6%A1%A3/">&#x4F20;&#x9001;&#x95E8;</a></p>
<hr>
<h2 id="&#x6CE8;&#x89E3;&#x7B80;&#x4ECB;"><a href="#&#x6CE8;&#x89E3;&#x7B80;&#x4ECB;" class="headerlink" title="&#x6CE8;&#x89E3;&#x7B80;&#x4ECB;"></a>&#x6CE8;&#x89E3;&#x7B80;&#x4ECB;</h2><h3 id="&#x6CE8;&#x89E3;"><a href="#&#x6CE8;&#x89E3;" class="headerlink" title="&#x6CE8;&#x89E3;"></a>&#x6CE8;&#x89E3;</h3><p>Annontation&#x662F;Java5&#x5F00;&#x59CB;&#x5F15;&#x5165;&#x7684;&#x65B0;&#x7279;&#x5F81;&#xFF0C;&#x4E2D;&#x6587;&#x540D;&#x79F0;&#x53EB;&#x6CE8;&#x89E3;&#x3002;&#x5B83;&#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x79CD;&#x5B89;&#x5168;&#x7684;&#x7C7B;&#x4F3C;&#x6CE8;&#x91CA;&#x7684;&#x673A;&#x5236;&#xFF0C;&#x7528;&#x6765;&#x5C06;&#x4EFB;&#x4F55;&#x7684;&#x4FE1;&#x606F;&#x6216;&#x5143;&#x6570;&#x636E;&#xFF08;metadata&#xFF09;&#x4E0E;&#x7A0B;&#x5E8F;&#x5143;&#x7D20;&#xFF08;&#x7C7B;&#x3001;&#x65B9;&#x6CD5;&#x3001;&#x6210;&#x5458;&#x53D8;&#x91CF;&#x7B49;&#xFF09;&#x8FDB;&#x884C;&#x5173;&#x8054;&#x3002;&#x4E3A;&#x7A0B;&#x5E8F;&#x7684;&#x5143;&#x7D20;&#xFF08;&#x7C7B;&#x3001;&#x65B9;&#x6CD5;&#x3001;&#x6210;&#x5458;&#x53D8;&#x91CF;&#xFF09;&#x52A0;&#x4E0A;&#x66F4;&#x76F4;&#x89C2;&#x66F4;&#x660E;&#x4E86;&#x7684;&#x8BF4;&#x660E;&#xFF0C;&#x8FD9;&#x4E9B;&#x8BF4;&#x660E;&#x4FE1;&#x606F;&#x662F;&#x4E0E;&#x7A0B;&#x5E8F;&#x7684;&#x4E1A;&#x52A1;&#x903B;&#x8F91;&#x65E0;&#x5173;&#xFF0C;&#x5E76;&#x4E14;&#x4F9B;&#x6307;&#x5B9A;&#x7684;&#x5DE5;&#x5177;&#x6216;&#x6846;&#x67B6;&#x4F7F;&#x7528;&#x3002;Annontation&#x50CF;&#x4E00;&#x79CD;&#x4FEE;&#x9970;&#x7B26;&#x4E00;&#x6837;&#xFF0C;&#x5E94;&#x7528;&#x4E8E;&#x5305;&#x3001;&#x7C7B;&#x578B;&#x3001;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x3001;&#x65B9;&#x6CD5;&#x3001;&#x6210;&#x5458;&#x53D8;&#x91CF;&#x3001;&#x53C2;&#x6570;&#x53CA;&#x672C;&#x5730;&#x53D8;&#x91CF;&#x7684;&#x58F0;&#x660E;&#x8BED;&#x53E5;&#x4E2D;&#x3002;</p>
<p>&#x6CE8;&#x89E3;&#x662F;&#x4E00;&#x79CD;&#x5143;&#x6570;&#x636E;, &#x53EF;&#x4EE5;&#x6DFB;&#x52A0;&#x5230;java&#x4EE3;&#x7801;&#x4E2D;. &#x7C7B;&#x3001;&#x65B9;&#x6CD5;&#x3001;&#x53D8;&#x91CF;&#x3001;&#x53C2;&#x6570;&#x3001;&#x5305;&#x90FD;&#x53EF;&#x4EE5;&#x88AB;&#x6CE8;&#x89E3;&#xFF0C;&#x6CE8;&#x89E3;&#x5BF9;&#x6CE8;&#x89E3;&#x7684;&#x4EE3;&#x7801;&#x6CA1;&#x6709;&#x76F4;&#x63A5;&#x5F71;&#x54CD;&#x3002;&#x4E4B;&#x6240;&#x4EE5;&#x4EA7;&#x751F;&#x4F5C;&#x7528;, &#x662F;&#x5BF9;&#x5176;&#x89E3;&#x6790;&#x540E;&#x505A;&#x4E86;&#x76F8;&#x5E94;&#x7684;&#x5904;&#x7406;. &#x6CE8;&#x89E3;&#x4EC5;&#x4EC5;&#x53EA;&#x662F;&#x4E2A;&#x6807;&#x8BB0;&#x3002;</p>
<p>&#x5B9A;&#x4E49;&#x6CE8;&#x89E3;&#x7528;&#x7684;&#x5173;&#x952E;&#x5B57;&#x662F;@interface</p>
<h3 id="&#x6CE8;&#x89E3;&#x7684;&#x7528;&#x5904;"><a href="#&#x6CE8;&#x89E3;&#x7684;&#x7528;&#x5904;" class="headerlink" title="&#x6CE8;&#x89E3;&#x7684;&#x7528;&#x5904;"></a>&#x6CE8;&#x89E3;&#x7684;&#x7528;&#x5904;</h3><ul>
<li>&#x751F;&#x6210;&#x6587;&#x6863;&#xFF0C;&#x7F16;&#x8BD1;&#x8FDB;&#x884C;&#x68C0;&#x67E5;&#x3002;&#x8FD9;&#x662F;&#x6700;&#x5E38;&#x89C1;&#x7684;&#xFF0C;&#x5373;<a href="http://tiimor.cn/Javadoc-%E4%BB%A3%E7%A0%81%E6%96%87%E6%A1%A3/">Javadoc&#x4EE3;&#x7801;&#x6CE8;&#x89E3;</a></li>
<li>&#x8DDF;&#x8E2A;&#x4EE3;&#x7801;&#x4F9D;&#x8D56;&#x6027;&#xFF0C;&#x5B9E;&#x73B0;&#x66FF;&#x4EE3;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x529F;&#x80FD;&#x3002;&#x5982;EventBus&#x3001;ButterKnife&#x3001;Dagger2&#x4F9D;&#x8D56;&#x6CE8;&#x5165;&#x7B49;&#xFF0C;<strong>&#x672C;&#x7BC7;&#x8BB0;&#x5F55;&#x4E00;&#x6B21;&#x7F16;&#x8BD1;&#x6CE8;&#x89E3;&#x4F7F;&#x7528;&#x8FC7;&#x7A0B;</strong>&#x3002;</li>
</ul>
<h3 id="&#x5143;&#x6CE8;&#x89E3;"><a href="#&#x5143;&#x6CE8;&#x89E3;" class="headerlink" title="&#x5143;&#x6CE8;&#x89E3;"></a>&#x5143;&#x6CE8;&#x89E3;</h3><p>java.lang.annotation&#x63D0;&#x4F9B;&#x4E86;&#x56DB;&#x79CD;&#x5143;&#x6CE8;&#x89E3;&#xFF0C;&#x4E13;&#x95E8;&#x6CE8;&#x89E3;&#x5176;&#x4ED6;&#x7684;&#x6CE8;&#x89E3;&#xFF1A;</p>
<ul>
<li><p><strong>@Documented</strong> &#x2013;&#x6CE8;&#x89E3;&#x662F;&#x5426;&#x5C06;&#x5305;&#x542B;&#x5728;Javadoc&#x6587;&#x6863;&#x4E2D;</p>
</li>
<li><p><strong>@Retention</strong> &#x2013;&#x4EC0;&#x4E48;&#x65F6;&#x5019;&#x4F7F;&#x7528;&#x8BE5;&#x6CE8;&#x89E3;&#xFF0C;&#x6709;&#x4E09;&#x79CD;&#x9009;&#x62E9;&#xFF0C;&#x9ED8;&#x8BA4;&#x4E3A;CLASS</p>
<ul>
<li>RetentionPolicy.SOURCE : &#x5728;&#x7F16;&#x8BD1;&#x9636;&#x6BB5;&#x4E22;&#x5F03;&#x3002;&#x8FD9;&#x4E9B;&#x6CE8;&#x89E3;&#x5728;&#x7F16;&#x8BD1;&#x7ED3;&#x675F;&#x4E4B;&#x540E;&#x5C31;&#x4E0D;&#x518D;&#x6709;&#x4EFB;&#x4F55;&#x610F;&#x4E49;&#xFF0C;&#x6240;&#x4EE5;&#x5B83;&#x4EEC;&#x4E0D;&#x4F1A;&#x5199;&#x5165;&#x5B57;&#x8282;&#x7801;&#x3002;@Override, @SuppressWarnings&#x90FD;&#x5C5E;&#x4E8E;&#x8FD9;&#x7C7B;&#x6CE8;&#x89E3;&#x3002;</li>
<li>RetentionPolicy.CLASS : &#x5728;&#x7C7B;&#x52A0;&#x8F7D;&#x7684;&#x65F6;&#x5019;&#x4E22;&#x5F03;&#x3002;&#x5728;&#x5B57;&#x8282;&#x7801;&#x6587;&#x4EF6;&#x7684;&#x5904;&#x7406;&#x4E2D;&#x6709;&#x7528;&#x3002;&#x6CE8;&#x89E3;&#x9ED8;&#x8BA4;&#x4F7F;&#x7528;&#x8FD9;&#x79CD;&#x65B9;&#x5F0F;</li>
<li>RetentionPolicy.RUNTIME : &#x59CB;&#x7EC8;&#x4E0D;&#x4F1A;&#x4E22;&#x5F03;&#xFF0C;&#x8FD0;&#x884C;&#x671F;&#x4E5F;&#x4FDD;&#x7559;&#x8BE5;&#x6CE8;&#x89E3;&#xFF0C;&#x56E0;&#x6B64;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x53CD;&#x5C04;&#x673A;&#x5236;&#x8BFB;&#x53D6;&#x8BE5;&#x6CE8;&#x89E3;&#x7684;&#x4FE1;&#x606F;&#x3002;</li>
</ul>
</li>
<li><p><strong>@Target</strong> &#x2013;&#x8868;&#x793A;&#x8BE5;&#x6CE8;&#x89E3;&#x7528;&#x4E8E;&#x4EC0;&#x4E48;&#x5730;&#x65B9;&#x3002;&#x9ED8;&#x8BA4;&#x503C;&#x4E3A;&#x4EFB;&#x4F55;&#x5143;&#x7D20;&#xFF0C;&#x8868;&#x793A;&#x8BE5;&#x6CE8;&#x89E3;&#x7528;&#x4E8E;&#x4EC0;&#x4E48;&#x5730;&#x65B9;&#x3002;&#x53EF;&#x7528;&#x7684;ElementType&#x53C2;&#x6570;&#x5305;&#x62EC;</p>
<ul>
<li>ElementType.CONSTRUCTOR:&#x7528;&#x4E8E;&#x63CF;&#x8FF0;&#x6784;&#x9020;&#x5668;</li>
<li>ElementType.FIELD:&#x6210;&#x5458;&#x53D8;&#x91CF;&#x3001;&#x5BF9;&#x8C61;&#x3001;&#x5C5E;&#x6027;&#xFF08;&#x5305;&#x62EC;enum&#x5B9E;&#x4F8B;&#xFF09;</li>
<li>ElementType.LOCAL_VARIABLE:&#x7528;&#x4E8E;&#x63CF;&#x8FF0;&#x5C40;&#x90E8;&#x53D8;&#x91CF;</li>
<li>ElementType.METHOD:&#x7528;&#x4E8E;&#x63CF;&#x8FF0;&#x65B9;&#x6CD5;</li>
<li>ElementType.PACKAGE:&#x7528;&#x4E8E;&#x63CF;&#x8FF0;&#x5305;</li>
<li>ElementType.PARAMETER:&#x7528;&#x4E8E;&#x63CF;&#x8FF0;&#x53C2;&#x6570;</li>
<li>ElementType.TYPE:&#x7528;&#x4E8E;&#x63CF;&#x8FF0;&#x7C7B;&#x3001;&#x63A5;&#x53E3;(&#x5305;&#x62EC;&#x6CE8;&#x89E3;&#x7C7B;&#x578B;) &#x6216;enum&#x58F0;&#x660E;</li>
</ul>
</li>
<li><p><strong>@Inherited</strong> &#x2013; &#x662F;&#x5426;&#x5141;&#x8BB8;&#x5B50;&#x7C7B;&#x7EE7;&#x627F;&#x8BE5;&#x6CE8;&#x89E3;&#xFF0C;&#x9ED8;&#x8BA4;&#x4E3A;false</p>
</li>
</ul>
<h2 id="Android&#x4E2D;&#x4F7F;&#x7528;&#x7F16;&#x8BD1;&#x65F6;&#x6CE8;&#x89E3;&#xFF0C;&#x81EA;&#x52A8;&#x751F;&#x6210;&#x4EE3;&#x7801;"><a href="#Android&#x4E2D;&#x4F7F;&#x7528;&#x7F16;&#x8BD1;&#x65F6;&#x6CE8;&#x89E3;&#xFF0C;&#x81EA;&#x52A8;&#x751F;&#x6210;&#x4EE3;&#x7801;" class="headerlink" title="Android&#x4E2D;&#x4F7F;&#x7528;&#x7F16;&#x8BD1;&#x65F6;&#x6CE8;&#x89E3;&#xFF0C;&#x81EA;&#x52A8;&#x751F;&#x6210;&#x4EE3;&#x7801;"></a>Android&#x4E2D;&#x4F7F;&#x7528;&#x7F16;&#x8BD1;&#x65F6;&#x6CE8;&#x89E3;&#xFF0C;&#x81EA;&#x52A8;&#x751F;&#x6210;&#x4EE3;&#x7801;</h2><p><strong>&#x8FD9;&#x91CC;&#x53EA;&#x8BB2;&#x89E3;&#x7F16;&#x8BD1;&#x6CE8;&#x89E3;&#xFF0C;&#x5176;&#x4ED6;&#x6CE8;&#x89E3;&#x5F85;&#x7EED;~~~</strong></p>
<hr>
<p><strong><a href="https://github.com/VeiZhang/Downloader" target="_blank" rel="noopener">Downloader&#x6E90;&#x7801;&#x4F20;&#x9001;&#x95E8;</a></strong></p>
<hr>
<p><img src="http://cdn.tiimor.cn/images/Annotation%E9%A1%B9%E7%9B%AE%E7%BB%93%E6%9E%84.png" alt="Annotations&#x9879;&#x76EE;&#x7ED3;&#x6784;"></p>
<ul>
<li>DownloadAnnotations&#xFF1A;<strong>Java&#x5DE5;&#x7A0B;</strong>&#xFF0C;&#x7533;&#x660E;&#x4F7F;&#x7528;&#x7684;&#x6CE8;&#x89E3;</li>
<li>DownloadCompiler&#xFF1A;<strong>Java&#x5DE5;&#x7A0B;</strong>&#xFF0C;&#x7528;&#x4E8E;&#x7F16;&#x8BD1;&#x671F;&#x95F4;&#x81EA;&#x52A8;&#x751F;&#x6210;&#x4EE3;&#x7801;</li>
<li>DownloaderLibrary&#xFF1A;&#x4E0B;&#x8F7D;&#x4F9D;&#x8D56;&#x5E93;</li>
<li>Demo&#xFF1A;&#x6D4B;&#x8BD5;&#x793A;&#x4F8B;</li>
</ul>
<h3 id="&#x521B;&#x5EFA;&#x81EA;&#x5B9A;&#x4E49;&#x6CE8;&#x89E3;"><a href="#&#x521B;&#x5EFA;&#x81EA;&#x5B9A;&#x4E49;&#x6CE8;&#x89E3;" class="headerlink" title="&#x521B;&#x5EFA;&#x81EA;&#x5B9A;&#x4E49;&#x6CE8;&#x89E3;"></a>&#x521B;&#x5EFA;&#x81EA;&#x5B9A;&#x4E49;&#x6CE8;&#x89E3;</h3><p>&#x521B;&#x5EFA;<strong>Java&#x5DE5;&#x7A0B;</strong>&#xFF1A;DownloadAnnotations</p>
<ul>
<li><p>&#x58F0;&#x660E;&#x4E00;&#x4E2A;Download&#x6CE8;&#x89E3;&#xFF0C;&#x58F0;&#x660E;&#x5468;&#x671F;&#x4E3A;Class&#xFF0C;&#x4F5C;&#x7528;&#x57DF;&#x4E3A;&#x65B9;&#x6CD5;</p>
  <figure class="highlight less"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="variable">@Retention</span>(RetentionPolicy.CLASS)</span><br><span class="line"><span class="variable">@Target</span>(ElementType.METHOD)</span><br><span class="line">public <span class="variable">@interface</span> Download</span><br><span class="line">{</span><br><span class="line">	<span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * &#x4E0B;&#x8F7D;&#x5F00;&#x59CB;&#xFF0C;&#x83B7;&#x53D6;&#x6587;&#x4EF6;&#x5927;&#x5C0F;</span></span><br><span class="line"><span class="comment">	 * @see com.excellence.downloader.FileDownloader.DownloadTask#getFileSize()</span></span><br><span class="line"><span class="comment">	 *</span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="variable">@Retention</span>(RetentionPolicy.CLASS)</span><br><span class="line">	<span class="variable">@Target</span>(ElementType.METHOD)</span><br><span class="line">	<span class="variable">@interface</span> onPreExecute</span><br><span class="line">	{</span><br><span class="line">		<span class="selector-tag">String</span><span class="selector-attr">[]</span> <span class="selector-tag">value</span>() <span class="selector-tag">default</span> { <span class="selector-tag">NO_URL</span> };</span><br><span class="line">	}</span><br><span class="line">}</span><br></pre></td></tr></tbody></table></figure>
</li>
<li><p>DownloadAnnotations&#x7684;build.gradle&#x914D;&#x7F6E;</p>
  <figure class="highlight gradle"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">apply plugin: <span class="string">&apos;java&apos;</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">dependencies</span> {</span><br><span class="line">    <span class="keyword">compile</span> <span class="keyword">fileTree</span>(dir: <span class="string">&apos;libs&apos;</span>, <span class="keyword">include</span>: [<span class="string">&apos;*.jar&apos;</span>])</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">tasks.withType(JavaCompile) {</span><br><span class="line">    <span class="keyword">options</span>.encoding = <span class="string">&quot;UTF-8&quot;</span></span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="keyword">sourceCompatibility</span> = JavaVersion.VERSION_1_7</span><br><span class="line"><span class="keyword">targetCompatibility</span> = JavaVersion.VERSION_1_7</span><br></pre></td></tr></tbody></table></figure>
</li>
</ul>
<h3 id="&#x89E3;&#x6790;&#x7F16;&#x8BD1;&#x65F6;&#x6CE8;&#x89E3;"><a href="#&#x89E3;&#x6790;&#x7F16;&#x8BD1;&#x65F6;&#x6CE8;&#x89E3;" class="headerlink" title="&#x89E3;&#x6790;&#x7F16;&#x8BD1;&#x65F6;&#x6CE8;&#x89E3;"></a>&#x89E3;&#x6790;&#x7F16;&#x8BD1;&#x65F6;&#x6CE8;&#x89E3;</h3><p>&#x521B;&#x5EFA;<strong>Java&#x5DE5;&#x7A0B;</strong>&#xFF1A;DownloadCompiler</p>
<p>&#x89E3;&#x6790;&#x7F16;&#x8BD1;&#x65F6;&#x6CE8;&#x89E3;&#x9700;&#x8981;&#x7EE7;&#x627F;AbstractProcessor&#xFF0C;&#x5E76;&#x4E14;&#x4F7F;&#x7528;&#x6CE8;&#x89E3;<code>@AutoService(Processor.class)</code>&#xFF0C;&#x8BE5;&#x6CE8;&#x89E3;&#x5728;&#x7F16;&#x8BD1;&#x65F6;<strong>&#x81EA;&#x52A8;&#x6267;&#x884C;</strong>&#x88AB;&#x6CE8;&#x89E3;&#x7684;&#x7C7B;&#xFF0C;&#x5373;<strong>&#x81EA;&#x52A8;&#x6267;&#x884C;</strong>&#x8BE5;&#x7C7B;&#x7684;Java&#x7A0B;&#x5E8F;&#xFF0C;&#x7528;&#x4E8E;&#x521B;&#x5EFA;&#x7C7B;&#x6587;&#x4EF6;&#x3002;</p>
<ul>
<li><p>DownloadProcessor&#x4E8B;&#x4EF6;&#x6CE8;&#x89E3;&#x626B;&#x63CF;&#x5668;</p>
  <figure class="highlight aspectj"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@AutoService</span>(Processor.class)</span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">DownloadProcessor</span> <span class="keyword">extends</span> <span class="title">AbstractProcessor</span></span></span><br><span class="line"><span class="class"></span>{</span><br><span class="line">	<span class="keyword">private</span> ElementHandler mElementHandler = <span class="keyword">null</span>;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * &#x6BCF;&#x4E00;&#x4E2A;&#x6CE8;&#x89E3;&#x5904;&#x7406;&#x5668;&#x7C7B;&#x90FD;&#x5FC5;&#x987B;&#x6709;&#x4E00;&#x4E2A;&#x7A7A;&#x7684;&#x6784;&#x9020;&#x51FD;&#x6570;&#x3002;&#x7136;&#x800C;&#xFF0C;&#x8FD9;&#x91CC;&#x6709;&#x4E00;&#x4E2A;&#x7279;&#x6B8A;&#x7684;{<span class="doctag">@link</span> #init}&#x65B9;&#x6CD5;&#xFF0C;&#x5B83;&#x4F1A;&#x88AB;&#x6CE8;&#x89E3;&#x5904;&#x7406;&#x5DE5;&#x5177;&#x8C03;&#x7528;&#xFF0C;&#x5E76;&#x8F93;&#x5165;{<span class="doctag">@link</span> ProcessingEnvironment}&#x53C2;&#x6570;&#x3002;{<span class="doctag">@link</span> ProcessingEnvironment}&#x63D0;&#x4F9B;&#x5F88;&#x591A;&#x6709;&#x7528;&#x7684;&#x5DE5;&#x5177;&#x7C7B;{<span class="doctag">@link</span> Elements}&#x3001;{<span class="doctag">@link</span> Types}&#x3001;{<span class="doctag">@link</span> Filer}&#x3002;</span></span><br><span class="line"><span class="comment">	 *</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> processingEnvironment</span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="meta">@Override</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">synchronized</span> <span class="keyword">void</span> init(ProcessingEnvironment processingEnvironment)</span><br><span class="line">	{</span><br><span class="line">		<span class="keyword">super</span>.init(processingEnvironment);</span><br><span class="line">		mElementHandler = <span class="keyword">new</span> ElementHandler(processingEnvironment.getFiler(), processingEnvironment.getElementUtils());</span><br><span class="line">	}</span><br><span class="line"></span><br><span class="line">	<span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * &#x5FC5;&#x987B;&#x6307;&#x5B9A;&#xFF0C;&#x8FD9;&#x4E2A;&#x6CE8;&#x89E3;&#x5904;&#x7406;&#x5668;&#x662F;&#x6CE8;&#x518C;&#x7ED9;&#x54EA;&#x4E2A;&#x6CE8;&#x89E3;&#x7684;&#x3002;&#x6CE8;&#x610F;&#xFF0C;&#x5B83;&#x7684;&#x8FD4;&#x56DE;&#x503C;&#x662F;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x96C6;&#x5408;&#xFF0C;&#x5305;&#x542B;&#x672C;&#x5904;&#x7406;&#x5668;&#x60F3;&#x8981;&#x5904;&#x7406;&#x7684;&#x6CE8;&#x89E3;&#x7C7B;&#x578B;&#x7684;&#x5408;&#x6CD5;&#x5168;&#x79F0;&#x3002;&#x6362;&#x53E5;&#x8BDD;&#x8BF4;&#xFF0C;&#x5728;&#x8FD9;&#x91CC;&#x5B9A;&#x4E49;&#x4F60;&#x7684;&#x6CE8;&#x89E3;&#x5904;&#x7406;&#x5668;&#x6CE8;&#x518C;&#x5230;&#x54EA;&#x4E9B;&#x6CE8;&#x89E3;&#x4E0A;&#x3002;</span></span><br><span class="line"><span class="comment">	 *</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="meta">@Override</span></span><br><span class="line">	<span class="keyword">public</span> Set&lt;String&gt; getSupportedAnnotationTypes()</span><br><span class="line">	{</span><br><span class="line">		Set&lt;String&gt; annotations = <span class="keyword">new</span> LinkedHashSet&lt;&gt;();</span><br><span class="line">		annotations.add(Download.onPreExecute.class.getCanonicalName());</span><br><span class="line">		<span class="keyword">return</span> annotations;</span><br><span class="line">	}</span><br><span class="line"></span><br><span class="line">	<span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * &#x7528;&#x6765;&#x6307;&#x5B9A;&#x4F60;&#x4F7F;&#x7528;&#x7684;Java&#x7248;&#x672C;&#x3002;</span></span><br><span class="line"><span class="comment">	 *</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="meta">@Override</span></span><br><span class="line">	<span class="keyword">public</span> SourceVersion getSupportedSourceVersion()</span><br><span class="line">	{</span><br><span class="line">		<span class="function"><span class="keyword">return</span> SourceVersion.<span class="title">latestSupported</span><span class="params">()</span></span>;</span><br><span class="line">	}</span><br><span class="line"></span><br><span class="line">	<span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * &#x8FD9;&#x76F8;&#x5F53;&#x4E8E;&#x6BCF;&#x4E2A;&#x5904;&#x7406;&#x5668;&#x7684;&#x4E3B;&#x51FD;&#x6570;main()&#x3002; &#x5728;&#x8FD9;&#x91CC;&#x5199;&#x626B;&#x63CF;&#x3001;&#x8BC4;&#x4F30;&#x548C;&#x5904;&#x7406;&#x6CE8;&#x89E3;&#x7684;&#x4EE3;&#x7801;&#xFF0C;&#x4EE5;&#x53CA;&#x751F;&#x6210;Java&#x6587;&#x4EF6;&#x3002;&#x8F93;&#x5165;&#x53C2;&#x6570;{<span class="doctag">@link</span> RoundEnvironment}&#xFF0C;&#x53EF;&#x4EE5;&#x8BA9;&#x67E5;&#x8BE2;&#x51FA;&#x5305;&#x542B;&#x7279;&#x5B9A;&#x6CE8;&#x89E3;&#x7684;&#x88AB;&#x6CE8;&#x89E3;&#x5143;&#x7D20;&#x3002;</span></span><br><span class="line"><span class="comment">	 * &#x8BE5;&#x65B9;&#x6CD5;&#x8FD4;&#x56DE;ture&#x8868;&#x793A;&#x8BE5;&#x6CE8;&#x89E3;&#x5DF2;&#x7ECF;&#x88AB;&#x5904;&#x7406;, &#x540E;&#x7EED;&#x4E0D;&#x4F1A;&#x518D;&#x6709;&#x5176;&#x4ED6;&#x5904;&#x7406;&#x5668;&#x5904;&#x7406;; &#x8FD4;&#x56DE;false&#x8868;&#x793A;&#x4ECD;&#x53EF;&#x88AB;&#x5176;&#x4ED6;&#x5904;&#x7406;&#x5668;&#x5904;&#x7406;</span></span><br><span class="line"><span class="comment">	 *</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> set</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> roundEnv</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="meta">@Override</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">boolean</span> process(Set&lt;? <span class="keyword">extends</span> TypeElement&gt; set, RoundEnvironment roundEnv)</span><br><span class="line">	{</span><br><span class="line">		mElementHandler.clean();</span><br><span class="line">		mElementHandler.handleDownload(roundEnv);</span><br><span class="line">		mElementHandler.createProxyFile();</span><br><span class="line">		<span class="keyword">return</span> <span class="keyword">true</span>;</span><br><span class="line">	}</span><br><span class="line">}</span><br></pre></td></tr></tbody></table></figure>
</li>
<li><p><a href="https://github.com/VeiZhang/Downloader/blob/master/DownloadCompiler/src/main/java/com/excellence/compiler/ElementHandler.java" target="_blank" rel="noopener">ElementHandler</a>&#x5143;&#x7D20;&#x5904;&#x7406;&#xFF08;&#x4EE3;&#x7801;&#x8FC7;&#x957F;&#xFF0C;&#x8BF7;&#x67E5;&#x770B;&#x6E90;&#x7801;&#xFF09;</p>
<ul>
<li><p>&#x7F16;&#x8BD1;&#x65F6;&#x81EA;&#x52A8;&#x521B;&#x5EFA;&#x4E8B;&#x4EF6;&#x4EE3;&#x7406;&#x7684;&#x7C7B;&#x6587;&#x4EF6;&#x7684;&#x7BA1;&#x7406;&#x7C7B;&#xFF0C;&#x7528;&#x4E8E;&#x7BA1;&#x7406;&#x6709;&#x6CE8;&#x518C;&#x4EE3;&#x7406;&#x7684;&#x7C7B;&#xFF0C;&#x751F;&#x6210;&#x8DEF;&#x5F84;&#xFF1A;<code>Demo/build/generated/source/apt/debug/com/excellence/downloader/ProxyClassCounter</code><br><img src="http://cdn.tiimor.cn/images/ProxyClassCounter.png" alt="ProxyClassCounter"></p>
</li>
<li><p>&#x7F16;&#x8BD1;&#x65F6;&#x81EA;&#x52A8;&#x521B;&#x5EFA;&#x4E8B;&#x4EF6;&#x4EE3;&#x7406;&#x7684;&#x7C7B;&#x6587;&#x4EF6;&#xFF0C;&#x7528;&#x4E8E;&#x53D1;&#x9001;&#x76D1;&#x542C;&#x63A5;&#x53E3;&#xFF0C;&#x751F;&#x6210;&#x7C7B;&#x6587;&#x4EF6;&#x7684;&#x8DEF;&#x5F84;&#xFF1A;<code>Demo/build/generated/source/apt/debug/com/zv/downloader/downloader/SingleThreadActivity$$DownloadListenerProxy</code><br><img src="http://cdn.tiimor.cn/images/SingleThreadActivity$$DownloadListenerProxy.png" alt="SingleThreadActivity$$DownloadListenerProxy"></p>
</li>
</ul>
</li>
<li><p>DownloadCompiler&#x7684;build.gradle&#x914D;&#x7F6E;</p>
<ul>
<li><code>com.google.auto.service:auto-service:1.0-rc2</code> &#x8C37;&#x6B4C;&#x63D0;&#x4F9B;&#x7684;Java &#x751F;&#x6210;&#x6E90;&#x4EE3;&#x7801;&#x5E93;</li>
<li><code>com.squareup:javapoet:1.9.0</code> &#x63D0;&#x4F9B;&#x4E86;&#x5404;&#x79CD; API &#x8BA9;&#x4F60;&#x7528;&#x5404;&#x79CD;&#x59FF;&#x52BF;&#x53BB;&#x751F;&#x6210; Java &#x4EE3;&#x7801;&#x6587;&#x4EF6;&#xFF0C;<a href="https://github.com/square/javapoet" target="_blank" rel="noopener">javapoet&#x4F20;&#x9001;&#x95E8;</a><figure class="highlight gradle"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">apply plugin: <span class="string">&apos;java&apos;</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">dependencies</span> {</span><br><span class="line">    <span class="keyword">compile</span> <span class="keyword">fileTree</span>(dir: <span class="string">&apos;libs&apos;</span>, <span class="keyword">include</span>: [<span class="string">&apos;*.jar&apos;</span>])</span><br><span class="line">    <span class="keyword">compile</span> <span class="string">&apos;com.google.auto.service:auto-service:1.0-rc2&apos;</span></span><br><span class="line">    <span class="keyword">compile</span> <span class="string">&apos;com.squareup:javapoet:1.9.0&apos;</span></span><br><span class="line">    <span class="keyword">compile</span> <span class="keyword">project</span>(<span class="string">&apos;:DownloadAnnotations&apos;</span>)</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">tasks.withType(JavaCompile) {</span><br><span class="line">    <span class="keyword">options</span>.encoding = <span class="string">&quot;UTF-8&quot;</span></span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="keyword">sourceCompatibility</span> = JavaVersion.VERSION_1_7</span><br><span class="line"><span class="keyword">targetCompatibility</span> = JavaVersion.VERSION_1_7</span><br></pre></td></tr></tbody></table></figure>
</li>
</ul>
</li>
</ul>
<p><strong>&#x5230;&#x6B64;&#x6CE8;&#x89E3;&#x751F;&#x6210;&#x4EE3;&#x7801;&#x8FC7;&#x7A0B;&#x7ED3;&#x675F;</strong></p>
<h2 id="Downloader&#x4F9D;&#x8D56;&#x5E93;&#x5904;&#x7406;&#x6CE8;&#x89E3;"><a href="#Downloader&#x4F9D;&#x8D56;&#x5E93;&#x5904;&#x7406;&#x6CE8;&#x89E3;" class="headerlink" title="Downloader&#x4F9D;&#x8D56;&#x5E93;&#x5904;&#x7406;&#x6CE8;&#x89E3;"></a>Downloader&#x4F9D;&#x8D56;&#x5E93;&#x5904;&#x7406;&#x6CE8;&#x89E3;</h2><ul>
<li><p>&#x6839;&#x636E;DownloadCompile&#x91CC;&#x7684;ElementHandler&#x7C7B;&#x521B;&#x5EFA;&#x6CE8;&#x89E3;&#x63A5;&#x53E3;ISchedulerListener</p>
  <figure class="highlight gradle"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="keyword">interface</span> ISchedulerListener&lt;<span class="keyword">TASK</span>&gt;</span><br><span class="line">{</span><br><span class="line">	<span class="keyword">void</span> onPreExecute(<span class="keyword">TASK</span> <span class="keyword">task</span>);</span><br><span class="line"></span><br><span class="line">	<span class="keyword">void</span> onProgressChange(<span class="keyword">TASK</span> <span class="keyword">task</span>);</span><br><span class="line"></span><br><span class="line">	<span class="keyword">void</span> onProgressSpeedChange(<span class="keyword">TASK</span> <span class="keyword">task</span>);</span><br><span class="line"></span><br><span class="line">	<span class="keyword">void</span> onCancel(<span class="keyword">TASK</span> <span class="keyword">task</span>);</span><br><span class="line"></span><br><span class="line">	<span class="keyword">void</span> onError(<span class="keyword">TASK</span> <span class="keyword">task</span>);</span><br><span class="line"></span><br><span class="line">	<span class="keyword">void</span> onSuccess(<span class="keyword">TASK</span> <span class="keyword">task</span>);</span><br><span class="line">}</span><br></pre></td></tr></tbody></table></figure>
</li>
<li><p>DownloadScheduler&#x4E8B;&#x4EF6;&#x8C03;&#x5EA6;&#x5668;&#xFF0C;&#x6CE8;&#x518C;&#x3001;&#x89E3;&#x7ED1;&#x3001;&#x76D1;&#x542C;&#xFF0C;&#x7528;&#x4E8E;&#x5904;&#x7406;&#x4EFB;&#x52A1;&#x72B6;&#x6001;&#x7684;&#x8C03;&#x5EA6;</p>
  <figure class="highlight cs"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * &#x521D;&#x59CB;&#x5316;&#x4EE3;&#x7406;&#x53C2;&#x6570;&#xFF0C;&#x83B7;&#x53D6;&#x6CE8;&#x89E3;&#x7C7B;&#x96C6;&#x5408;</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">private</span> <span class="keyword">void</span> <span class="title">initDownloadCounter</span>(<span class="params"></span>)</span></span><br><span class="line"><span class="function"></span>{</span><br><span class="line">	<span class="keyword">try</span></span><br><span class="line">	{</span><br><span class="line">		Class clazz = Class.forName(<span class="string">&quot;com.excellence.downloader.ProxyClassCounter&quot;</span>);</span><br><span class="line">		Method download = clazz.getMethod(<span class="string">&quot;getDownloadCounter&quot;</span>);</span><br><span class="line">		Object <span class="keyword">object</span> = clazz.newInstance();</span><br><span class="line">		Object downloadCounter = download.invoke(<span class="keyword">object</span>);</span><br><span class="line">		<span class="keyword">if</span> (downloadCounter != <span class="literal">null</span>)</span><br><span class="line">			mDownloadCounter = unmodifiableSet((Set&lt;String&gt;) downloadCounter);</span><br><span class="line">	}</span><br><span class="line">	<span class="keyword">catch</span> (ClassNotFoundException e)</span><br><span class="line">	{</span><br><span class="line">		e.printStackTrace();</span><br><span class="line">	}</span><br><span class="line">	<span class="keyword">catch</span> (NoSuchMethodException e)</span><br><span class="line">	{</span><br><span class="line">		e.printStackTrace();</span><br><span class="line">	}</span><br><span class="line">	<span class="keyword">catch</span> (InstantiationException e)</span><br><span class="line">	{</span><br><span class="line">		e.printStackTrace();</span><br><span class="line">	}</span><br><span class="line">	<span class="keyword">catch</span> (IllegalAccessException e)</span><br><span class="line">	{</span><br><span class="line">		e.printStackTrace();</span><br><span class="line">	}</span><br><span class="line">	<span class="keyword">catch</span> (InvocationTargetException e)</span><br><span class="line">	{</span><br><span class="line">		e.printStackTrace();</span><br><span class="line">	}</span><br><span class="line">}</span><br></pre></td></tr></tbody></table></figure>
</li>
</ul>
<h2 id="Demo&#x4F7F;&#x7528;&#x6CE8;&#x89E3;&#x76D1;&#x542C;"><a href="#Demo&#x4F7F;&#x7528;&#x6CE8;&#x89E3;&#x76D1;&#x542C;" class="headerlink" title="Demo&#x4F7F;&#x7528;&#x6CE8;&#x89E3;&#x76D1;&#x542C;"></a>Demo&#x4F7F;&#x7528;&#x6CE8;&#x89E3;&#x76D1;&#x542C;</h2><p>&#x4F7F;&#x7528;&#x65B9;&#x5F0F;<br></p><figure class="highlight cpp"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// &#x6CE8;&#x518C;</span></span><br><span class="line">Downloader.<span class="keyword">register</span>(<span class="keyword">this</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">// &#x89E3;&#x7ED1;</span></span><br><span class="line">Downloader.unregister(<span class="keyword">this</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">// &#x76D1;&#x542C;</span></span><br><span class="line">@Download.onPreExecute</span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">onPre</span><span class="params">(DownloadTask task)</span></span></span><br><span class="line"><span class="function"></span>{</span><br><span class="line">	<span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * &#x6CE8;&#x89E3;&#x53C2;&#x6570;&#x4E0D;&#x6DFB;&#x52A0;URL&#xFF0C;&#x5219;&#x83B7;&#x53D6;&#x5168;&#x90E8;&#x4EFB;&#x52A1;&#x7684;&#x4E0B;&#x8F7D;&#x76D1;&#x542C;&#xFF1B;</span></span><br><span class="line"><span class="comment">	 * &#x52A0;&#x4E86;URL&#xFF0C;&#x5219;&#x8FC7;&#x6EE4;&#x51FA;&#x5BF9;&#x5E94;&#x7684;&#x4EFB;&#x52A1;&#x7684;&#x4E0B;&#x8F7D;&#x76D1;&#x542C;</span></span><br><span class="line"><span class="comment">	 * &#x5982;&#xFF1A;@Download.onPreExecute({URL1, URL2})</span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">}</span><br></pre></td></tr></tbody></table></figure><p></p>
<h2 id="&#x611F;&#x8C22;"><a href="#&#x611F;&#x8C22;" class="headerlink" title="&#x611F;&#x8C22;"></a>&#x611F;&#x8C22;</h2><blockquote>
<ul>
<li><a href="http://www.cnblogs.com/whoislcj/p/6168641.html" target="_blank" rel="noopener">&#x603B;&#x674E;&#x5199;&#x4EE3;&#x7801;</a></li>
<li><a href="https://github.com/AriaLyy/Aria" target="_blank" rel="noopener">AriaLyy</a></li>
</ul>
</blockquote>
<script>
        document.querySelectorAll('.github-emoji')
          .forEach(el => {
            if (!el.dataset.src) { return; }
            const img = document.createElement('img');
            img.style = 'display:none !important;';
            img.src = el.dataset.src;
            img.addEventListener('error', () => {
              img.remove();
              el.style.color = 'inherit';
              el.style.backgroundImage = 'none';
              el.style.background = 'none';
            });
            img.addEventListener('load', () => {
              img.remove();
            });
            document.body.appendChild(img);
          });
      </script>
      
    </div>
    
    
    

    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div>谢谢老板，请尽情用红包来蹂躏我吧！！！</div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>赏</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="/uploads/wechatpay.jpg" alt="Tiimor 微信打赏">
        <p>微信打赏</p>
      </div>
    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="/uploads/alipay.jpg" alt="Tiimor 支付宝打赏">
        <p>支付宝打赏</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <!-- modify by zhangwei -->
            <!-- 文章底部标签图标 -->
            <a href="/tags/Java/" rel="tag"><i class="menu-item-icon fa fa-tag fa-fw"></i>Java</a>
          
            <!-- modify by zhangwei -->
            <!-- 文章底部标签图标 -->
            <a href="/tags/编译注解/" rel="tag"><i class="menu-item-icon fa fa-tag fa-fw"></i>编译注解</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/Android青铜篇-TextView属性/" rel="next" title="Android青铜篇-TextView属性">
                <i class="fa fa-chevron-left"></i> Android青铜篇-TextView属性
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/Android热修复-Sophix/" rel="prev" title="Android热修复-Sophix">
                Android热修复-Sophix <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
      
        <div id="gitment-container"></div>
      
    </div>

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image" src="/uploads/avatar.jpg" alt="Tiimor">
            
              <p class="site-author-name" itemprop="name">Tiimor</p>
              <p class="site-description motion-element" itemprop="description">安静地做一只攻城狮。</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">41</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">6</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">56</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          
            <div class="feed-link motion-element">
              <a href="/atom.xml" rel="alternate">
                <i class="fa fa-rss"></i>
                RSS
              </a>
            </div>
          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/VeiZhang" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i>GitHub</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="http://www.weibo.com/tiimor" target="_blank" title="微博">
                      
                        <i class="fa fa-fw fa-weibo"></i>微博</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://juejin.im/user/589972d0570c3500624fd791" target="_blank" title="掘金">
                      
                        <i class="fa fa-fw fa-anchor"></i>掘金</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="http://www.jianshu.com/u/93b886580243" target="_blank" title="简书">
                      
                        <i class="fa fa-fw fa-book"></i>简书</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="http://wpa.qq.com/msgrd?v=3&uin=690393541&site=qq&menu=yes" target="_blank" title="QQ">
                      
                        <i class="fa fa-fw fa-qq"></i>QQ</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="mailto:tiimor@qq.com" target="_blank" title="邮箱">
                      
                        <i class="fa fa-fw fa-envelope"></i>邮箱</a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#注解简介"><span class="nav-number">1.</span> <span class="nav-text">注解简介</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#注解"><span class="nav-number">1.1.</span> <span class="nav-text">注解</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#注解的用处"><span class="nav-number">1.2.</span> <span class="nav-text">注解的用处</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#元注解"><span class="nav-number">1.3.</span> <span class="nav-text">元注解</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Android中使用编译时注解，自动生成代码"><span class="nav-number">2.</span> <span class="nav-text">Android中使用编译时注解，自动生成代码</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#创建自定义注解"><span class="nav-number">2.1.</span> <span class="nav-text">创建自定义注解</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#解析编译时注解"><span class="nav-number">2.2.</span> <span class="nav-text">解析编译时注解</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Downloader依赖库处理注解"><span class="nav-number">3.</span> <span class="nav-text">Downloader依赖库处理注解</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Demo使用注解监听"><span class="nav-number">4.</span> <span class="nav-text">Demo使用注解监听</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#感谢"><span class="nav-number">5.</span> <span class="nav-text">感谢</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; 2017 &mdash; <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Tiimor</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Pisces</a></div>




        
<div class="busuanzi-count">
  <!-- modify by zhangwei -->
  <!-- 修改不蒜子统计脚本 -->
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      <i class="fa fa-user"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      
    </span>
  

  
    <span class="site-pv">
      <i class="fa fa-eye"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      
    </span>
  
</div>



<script>
  	var _mtac = {};
  	(function() {
  		var mta = document.createElement("script");
  		mta.src = "https://pingjs.qq.com/h5/stats.js?v2.0.4";
  		mta.setAttribute("name", "MTAH5");
  		mta.setAttribute("sid", "500425805");

  		var s = document.getElementsByTagName("script")[0];
  		s.parentNode.insertBefore(mta, s);
  	})();
</script>


  <script type="text/javascript">
    (function() {
      var hm = document.createElement("script");
      hm.src = "//tajs.qq.com/stats?sId=61441764";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
          <span id="scrollpercent"><span>0</span>%</span>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  











  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  

  
  
    <script type="text/javascript" src="/lib/canvas-nest/canvas-nest.min.js"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  







<!-- LOCAL: You can save these files to your site and update links -->
    
        
        <link rel="stylesheet" href="https://aimingoo.github.io/gitmint/style/default.css">
        <script src="https://aimingoo.github.io/gitmint/dist/gitmint.browser.js"></script>
    
<!-- END LOCAL -->

    

    
      <script type="text/javascript">
      function renderGitment(){
        var gitment = new Gitmint({
            <!-- modify by zhangwei -->
            <!-- 修复gitment评论页初始化错误@tiimor -->
            id: '1505023132000', 
            owner: 'VeiZhang',
            repo: 'veizhang.github.io',
            
            lang: "" || navigator.language || navigator.systemLanguage || navigator.userLanguage,
            
            oauth: {
            
            
                client_secret: '9919bc61413a89ea3eb156910d282e3103093e32',
            
                client_id: 'f08924ca58e61d6f51f4'
            }});
        gitment.render('gitment-container');
      }

      
      renderGitment();
      
      </script>
    







  




  
  
  
  <link rel="stylesheet" href="/lib/algolia-instant-search/instantsearch.min.css">

  
  
  <script src="/lib/algolia-instant-search/instantsearch.min.js"></script>
  

  <script src="/js/src/algolia-search.js?v=5.1.4"></script>



  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.4.js"></script>
  <script>AV.initialize("7aBs9I9Y3PjoN6ueX5J3AYQW-gzGzoHsz", "kboycyzaPNAYcUW8AkF3edeW");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  

  
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


  
  

  

  

  

  
  <!-- modify by zhangwei -->
  <!-- 动态时间小人 -->
  <!-- modify by zhangwei -->
<!-- 动态时间小人 -->
<!-- z-index -1 表示在最底层，不能悬浮也不能点击 -->
<!-- z-index auto 可以点击 -->
<!-- z-index 9999 无限大时，总是在最上层，会影响其他悬浮框 -->
<div id="dg" style="z-index: auto; position: fixed ! important; right: 0px; top: 0px;">  
    <table width 100% style="position: absolute; width:260px; right: 0px; top: 0px;">  
		<div>
			<embed wmode="transparent" src="http://cdn.tiimor.cn/images/dynamic_time.swf" quality="high" bgcolor="#ffffff" width="160" height="70" name="honehoneclock" align="middle" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">
		</div>
    </table>  
</div>
  
</body>
</html>
